/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ws;

import com.ebay.services.client.ClientConfig;
import com.ebay.services.client.FindingServiceClientFactory;
import com.ebay.services.finding.FindItemsByKeywordsRequest;
import com.ebay.services.finding.FindItemsByKeywordsResponse;
import com.ebay.services.finding.FindingServicePortType;
import com.ebay.services.finding.SearchItem;
import java.util.List;

/**
 *
 * @author Amaury
 */
public class CallEbayWS {
    
    public List<SearchItem> getSearchItem(String requete){
        
        ClientConfig config = new ClientConfig();
        config.setApplicationId("UniceMIA-16bc-475a-8f76-c689ed822caa");

        FindingServicePortType serviceClient = FindingServiceClientFactory.getServiceClient(config);
        
        FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();
        
        request.setKeywords(requete);
        
        
        FindItemsByKeywordsResponse result = serviceClient.findItemsByKeywords(request);

        try{
             List<SearchItem> items = result.getSearchResult().getItem();
//        for (SearchItem item : items) {
//            System.out.println(item.getTitle());
//        }
        
        
        return items;
        }catch(Exception e){
            return null;
        }
       
    }
    
    
    
}
